//
//  NYSView.m
//  NYS
//
//  Created by niyongsheng.github.io on 2021/8/9.
//  Copyright © 2021 NYS. ALL rights reserved.
//

#import "NYSExInputAlert.h"

@interface NYSExInputAlert ()
@property (weak, nonatomic) UIView *view;

@property (weak, nonatomic) IBOutlet UIButton *cancelBtn;
@property (weak, nonatomic) IBOutlet UIButton *sureBtn;
@end

@implementation NYSExInputAlert

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.view = [self loadViewFromNib];
    }
    return self;
}

- (instancetype)initWithCoder:(NSCoder *)coder
{
    self = [super initWithCoder:coder];
    if (self) {
        self.view = [self loadViewFromNib];
    }
    return self;
}

- (UIView*)loadViewFromNib {
    
    NSBundle *bundle = [NSBundle bundleForClass:[self class]];
    UINib *nib = [UINib nibWithNibName:NSStringFromClass([self class])
                                bundle:bundle];
    
    UIView *view = [nib instantiateWithOwner:self options:nil][0];
    
    view.frame = self.bounds;
    view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
    
    [self addSubview:view];
    
    [self setupView];
    
    return view;
    
}


- (void)setupView {
    
    ViewRadius(self, 10);
    _titleL.textColor = Theme_ColorValue;
    [_sureBtn setTitleColor:Theme_ColorValue forState:UIControlStateNormal];
}

- (IBAction)cancelOncliked:(UIButton *)sender {
    if (_block) {
        self.block(@"-1");
    }
}

- (IBAction)btnOncliked:(UIButton *)sender {
    if (_block) {
        self.block(_updateTF.text);
    }
}

- (void)updateData:(id)data {
  
}

@end
